<template>
  <div>
    <sign-canvas class="sign-canvas" ref="SignCanvas" :options="options" v-model="value"/>
    <img class="view-image" :src="value" width="150" height="150">
    <div class="sign-btns">
      <el-button @click="canvasClear">清空</el-button>
      <el-button @click="saveAsImg">保存</el-button>
      <el-button @click="downloadSignImg">下载</el-button>

<!--      <span id="loadNew" @click="loadNew()">新加载</span>-->
<!--      <span id="coverLoad" @click="coverLoad()">合并加载</span>-->
<!--      <span id="clear" @click="canvasClear()">清空</span>-->
<!--      <span id="save" @click="saveAsImg()">保存</span>-->
<!--      <span id="downL" @click="downloadSignImg()">下载</span>-->
    </div>
  </div>
</template>

<script>
import SignCanvas from '@/views/liuyucheng/plugin/SignCanvas.vue'

export default {
  name: 'SignNameModal',
  components: { SignCanvas },
  data() {
    return {
      value: null,
      options: {
        isSign: true, //签名模式 [Boolean] 默认为非签名模式,有线框, 当设置为true的时候没有任何线框
        isShowBorder: true //是否显示边框 [可选]
      }
    }
  },
  methods:{

    /**
     * 新加载图像
     */
    loadNew(){
      this.$refs.SignCanvas.loadNew('https://testfi.oss-cn-hangzhou.aliyuncs.com/1577178007000.png');
    },

    /**
     * 合并加载
     */
    coverLoad(){
      this.$refs.SignCanvas.coverLoad('https://testfi.oss-cn-hangzhou.aliyuncs.com/1577178007000.png');
    },

    /**
     * 清除画板
     */
    canvasClear(){
      this.$refs.SignCanvas.canvasClear();
    },

    /**
     * 保存图片
     */
    saveAsImg(){
      const img = this.$refs.SignCanvas.saveAsImg();
      alert(`image 的base64：${img}`);
    },

    /**
     * 下载图片
     */
    downloadSignImg(){
      this.$refs.SignCanvas.downloadSignImg();
    },

  }
}
</script>

<style lang="less" scoped>
</style>
